package com.ruoyi.shops.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.shops.domain.ShopReviews;
import com.ruoyi.shops.service.IShopReviewsService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 店铺评论Controller
 * 
 * @author ruoyi
 * @date 2025-11-04
 */
@RestController
@RequestMapping("/shops/reviews")
public class ShopReviewsController extends BaseController
{
    @Autowired
    private IShopReviewsService shopReviewsService;

    /**
     * 查询店铺评论列表
     */
    @RequiresPermissions("shops:reviews:list")
    @GetMapping("/list")
    public TableDataInfo list(ShopReviews shopReviews)
    {
        startPage();
        List<ShopReviews> list = shopReviewsService.selectShopReviewsList(shopReviews);
        return getDataTable(list);
    }

    /**
     * 导出店铺评论列表
     */
    @RequiresPermissions("shops:reviews:export")
    @Log(title = "店铺评论", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ShopReviews shopReviews)
    {
        List<ShopReviews> list = shopReviewsService.selectShopReviewsList(shopReviews);
        ExcelUtil<ShopReviews> util = new ExcelUtil<ShopReviews>(ShopReviews.class);
        util.exportExcel(response, list, "店铺评论数据");
    }

    /**
     * 获取店铺评论详细信息
     */
    @RequiresPermissions("shops:reviews:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(shopReviewsService.selectShopReviewsById(id));
    }

    /**
     * 新增店铺评论
     */
    @RequiresPermissions("shops:reviews:add")
    @Log(title = "店铺评论", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ShopReviews shopReviews)
    {
        return toAjax(shopReviewsService.insertShopReviews(shopReviews));
    }

    /**
     * 修改店铺评论
     */
    @RequiresPermissions("shops:reviews:edit")
    @Log(title = "店铺评论", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ShopReviews shopReviews)
    {
        return toAjax(shopReviewsService.updateShopReviews(shopReviews));
    }

    /**
     * 删除店铺评论
     */
    @RequiresPermissions("shops:reviews:remove")
    @Log(title = "店铺评论", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(shopReviewsService.deleteShopReviewsByIds(ids));
    }
}
